| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkMemory::PtrPool< T > Class Template Referencefinal

A pool of objects, allocated in the heap and tracked by their pointers. More...

## Public Member Functions
| PtrPool (UniquePtr< Allocator< T >> allocator=makeUnique< DefaultAllocator< T >>(), UniquePtr< Deallocator< T >> deallocator=makeUnique< DefaultDeallocator< T >>()) noexcept
| PtrPool (const PtrPool &) noexcept=delete
| PtrPool (PtrPool &&) noexcept=default
| ~PtrPool ()
unsigned long long | getPoolSize () const
unsigned long long | getFreeItemsCount () const
unsigned long long | getFlyingItemsCount () const
T * | getObject ()
void | releaseObject (T *object)
PtrPool & | operator= (const PtrPool &) noexcept=delete
PtrPool & | operator= (PtrPool &&) noexcept=default

## Detailed Description

### template<typename T>
class nkMemory::PtrPool< T >

A pool of objects, allocated in the heap and tracked by their pointers.

Can be used to keep objects around and reusing them many times. This helps in easing memory allocation / deallocation requests, this reducing calls to system.

## Constructor & Destructor Documentation

## ◆ PtrPool() [1/3]

template<typename T >

nkMemory::PtrPool< T >::PtrPool | ( | UniquePtr< Allocator< T >> | allocator = `makeUnique< DefaultAllocator< T >>()`,
|  | UniquePtr< Deallocator< T >> | deallocator = `makeUnique< DefaultDeallocator< T >>()`
| ) |  |
| noexcept

Constructor.

Parameters

  allocator | Allocator to use when a new object has to be allocated. The pool takes ownership of the allocator provided.
  deallocator | Deallocator to use when an object has to be freed. The pool takes ownership of the deallocator provided.

## ◆ PtrPool() [2/3]

template<typename T >

nkMemory::PtrPool< T >::PtrPool | ( | const PtrPool< T > & |  | ) |
| delete noexcept

Copy constructor.

## ◆ PtrPool() [3/3]

template<typename T >

nkMemory::PtrPool< T >::PtrPool | ( | PtrPool< T > && |  | ) |
| default noexcept

Move constructor.

## ◆ ~PtrPool()

template<typename T >

nkMemory::PtrPool< T >::~PtrPool | ( |  | ) |

Destructor.

## Member Function Documentation

## ◆ getPoolSize()

template<typename T >

unsigned long long nkMemory::PtrPool< T >::getPoolSize | ( |  | ) | const

Returns
  Current pool size.

## ◆ getFreeItemsCount()

template<typename T >

unsigned long long nkMemory::PtrPool< T >::getFreeItemsCount | ( |  | ) | const

Returns
  The number of items currently available in the pool.

## ◆ getFlyingItemsCount()

template<typename T >

unsigned long long nkMemory::PtrPool< T >::getFlyingItemsCount | ( |  | ) | const

Returns
  The number of items currently in use in the pool.

## ◆ getObject()

template<typename T >

T* nkMemory::PtrPool< T >::getObject | ( |  | ) |

Returns
  An object from the pool.

Remarks
  If objects are free in the pool, then one of them is returned. Else, a new allocation is triggered.

## ◆ releaseObject()

template<typename T >

void nkMemory::PtrPool< T >::releaseObject | ( | T * | object | ) |

Returns an object to the pool.

Parameters

  object | Object to return to the pool.

## ◆ operator=() [1/2]

template<typename T >

PtrPool& nkMemory::PtrPool< T >::operator= | ( | const PtrPool< T > & |  | ) |
| delete noexcept

Copy assignment.

## ◆ operator=() [2/2]

template<typename T >

PtrPool& nkMemory::PtrPool< T >::operator= | ( | PtrPool< T > && |  | ) |
| default noexcept

Move assignment.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsMemory/Pools/PtrPool.h